﻿using System;
using System.Drawing;
using Microsoft.Office.Core;
using Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.PowerPoint.STAMP.Core;
using Microsoft.Office.PowerPoint.STAMP.Properties;
using NUnit.Framework;
using Shape = Microsoft.Office.Interop.PowerPoint.Shape;

namespace Microsoft.Office.PowerPoint.STAMP.Test
{
    [TestFixture]
    public class UtilsPresentationTests
    {
        private Application _app;

        [SetUp]
        public void TestInitialise()
        {
            _app = new Application();
            _app.Presentations.Add(MsoTriState.msoFalse);
            _app.Presentations[1].Slides.Add(1, Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutBlank);
        }

        [TearDown]
        public void TestCleanup()
        {
            _app.Presentations[1].Close();
            _app.Quit();
            _app = null;
        }

        [Test()]
        public void DetermineShapeSizeTest()
        {
            var slide = _app.Presentations[1].Slides[1];

            RectangleF slideRectangle = new RectangleF(0, 0, 1000, 1000);
            RectangleF mediaRectangle = new RectangleF(0, 0, 500, 500);
            CaptionStyle style = new CaptionStyle();

            var SizeF = Utils.DetermineShapeSize(slideRectangle, mediaRectangle, style, "jamie mclean is goodjamie mclean is goodjamie mclean is goodjamie mclean is good", slide);

            Assert.AreEqual(1, 1);
        }


        [Test()]
        public void GetTagValue()
        {
            var slide = _app.Presentations[1].Slides[1];
           
            Shape txtBox = UtilPowerPoint.AddTextboxShape(slide, 0, 0, 0, 10);

            string name = "itemName";
            string guid = Guid.NewGuid().ToString();
            string bookMarkEntryName = "BookMarkExitName";
            string bookMarkExitName = "BookMarkEntryName";

            CaptionItem item = new CaptionItem
                                   {
                                       InternalId = guid,
                                       Name = name,
                                       BookMarkEntryName = bookMarkEntryName,
                                       BookMarkExitName = bookMarkExitName
                                   };
            string mediaId = "mediaId";

            UtilPowerPoint.SetTextboxCaptionDetails(txtBox, item, mediaId, "test");

            Assert.AreEqual(name, UtilPowerPoint.GetShapeTagValue(txtBox, Constants.CaptionItemSysName));
            Assert.AreEqual(guid, UtilPowerPoint.GetShapeTagValue(txtBox, Constants.CaptionInternalId));
            Assert.AreEqual(bookMarkExitName, UtilPowerPoint.GetShapeTagValue(txtBox, Constants.BookMarkExitName));
            Assert.AreEqual(bookMarkEntryName, UtilPowerPoint.GetShapeTagValue(txtBox, Constants.BookMarkEntryName));
            Assert.AreEqual(mediaId, UtilPowerPoint.GetShapeTagValue(txtBox, Constants.CaptionMediaId));

        }
    }
}